package com.dycloud.project.service.impl;


import com.dycloud.project.domain.UserLikeRecord;
import com.dycloud.project.mapper.UserLikeRecordMapper;
import com.dycloud.project.service.IUserLikeRecordService;
import com.dycloud.project.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author : renhang
 * @description UserLikeRecordServiceImpl
 * @date : 2025-07-02 23:21
 **/
@Service
public class UserLikeRecordServiceImpl implements IUserLikeRecordService {
    @Autowired
    private UserLikeRecordMapper userLikeRecordMapper;

    /**
     * 查询用户点赞记录
     *
     * @param id 用户点赞记录主键
     * @return 用户点赞记录
     */
    @Override
    public UserLikeRecord selectUserLikeRecordById(Long id) {
        return userLikeRecordMapper.selectUserLikeRecordById(id);
    }

    /**
     * 查询用户点赞记录列表
     *
     * @param userLikeRecord 用户点赞记录
     * @return 用户点赞记录
     */
    @Override
    public List<UserLikeRecord> selectUserLikeRecordList(UserLikeRecord userLikeRecord) {
        return userLikeRecordMapper.selectUserLikeRecordList(userLikeRecord);
    }

    /**
     * 新增用户点赞记录
     *
     * @param userLikeRecord 用户点赞记录
     * @return 结果
     */
    @Override
    public int insertUserLikeRecord(UserLikeRecord userLikeRecord) {
        userLikeRecord.setCreateTime(DateUtils.getNowDate());
        userLikeRecord.setUpdateTime(DateUtils.getNowDate());
        return userLikeRecordMapper.insertUserLikeRecord(userLikeRecord);
    }


    @Override
    public void deleteUserLikeRecord(String targetType, Long userId, Long id) {
        userLikeRecordMapper.deleteUserLikeRecord(targetType, userId, id);
    }

    @Override
    public UserLikeRecord queryUserIsLiked(String targetType, Long id, Long userId) {
        return userLikeRecordMapper.selectUserIsLiked(targetType, userId, id);
    }
}